﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 饼图
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Graphics g = this.CreateGraphics();
           Pen mypen = new Pen(Color.Blue,3);
           Point o1 = new Point(30,this.ClientSize.Height-100);
            Point o2 = new Point(this.ClientSize.Width-50,this.ClientSize.Height-100);
            g.DrawLine(mypen, o1, o2);
            Point o3 = new Point(30,30);
           g.DrawLine(mypen,o1,o3);
            Font f = new Font("宋体",12,FontStyle.Bold);
           g.DrawString("x",f,mypen.Brush,o2);
            g.DrawString("y",f,mypen.Brush,10,10);
          int x1, x2;
            double a,y2,y1;
            x1 = x2 = 0;
            y1 = 0; y2 = this.ClientSize.Height - 100;
            for (x2 = 0; x2 < this.ClientSize.Width;x2++ )
            {
                a=2*Math.PI*x2/(this.ClientSize.Width);
                y2= ( Math.Sin(a));
                y2 = (1 - y2) * (this.ClientSize.Height - 100) / 2;
                g.DrawLine(mypen,x1+30,(float)y1+120,x2+30,(float)y2+120);
                x1 = x2;
                y1 = y2;

            }
        }
     

        private void button2_Click(object sender, EventArgs e)
        {
            Pen p = new Pen(Color.Red);
            Graphics g = this.CreateGraphics();
            Rectangle r = new Rectangle(50,50,200,100);
            Brush b = new SolidBrush(Color.Blue);
            g.FillPie(p.Brush,r,0,60);
            g.FillPie(b,r,60,150);
            b = new SolidBrush(Color.Yellow);
            g.FillPie(b, r, 210, 150);
            
             
         
    
          
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Graphics g = Graphics.FromImage(pictureBox1.Image);
            Font f = new Font("隶书",80,FontStyle.Italic);
            Pen p = new Pen(Color.OrangeRed);
            g.DrawString("花开花落", f, p.Brush, 0,0);
            p.Dispose();
            g.Dispose();
            pictureBox1.Refresh();
        }
    }
}
